package org.semanticflash.rdf.io.rdfjson
{
	
	import com.bigflexlib.ds.container.zet.IRWSet;
	import com.bigflexlib.ds.container.zet.impl.RWDictionarySet;
	
	import org.semanticflash.rdf.io.RDFSetHandler;
	import org.semanticflash.rdf.triple.RDFTriple;
	import org.semanticflash.rdf.triple.RDFTripleUtil;
	import org.semanticflash.rdf.utils.AbstractRDFTest;
	import org.semanticflash.rdf.values.IRI;
	import org.semanticflash.rdf.values.RDFPlainLiteral;


	public class RDFJSONParserTest extends AbstractRDFTest
	{
		
		public function testMain( ):void
		{
		
			t(
				'{"http://example.org/about" : { "http://purl.org/dc/elements/1.1/title": [ { "type" : "literal" , "value" : "Anna\'s Homepage." } ]} }',
				[
					RDFTriple.instance( 
							IRI.instance( "http://example.org/about"), 
							IRI.instance( "http://purl.org/dc/elements/1.1/title" ), 
							RDFPlainLiteral.instance( "Anna's Homepage." )
							) 			
				]
			);			
			
						
		
		}
		
		
		
		
		private function t( json:String, triples:Array ):void
		{
		
			var s:IRWSet = new RWDictionarySet( );
		
			var p:RDFJSONParser = new RDFJSONParser( json, new RDFSetHandler( s ) );
					
			p.runner.run( );
			
			if ( ! RDFTripleUtil.testGraphEquivalence( triples, s.asArray ) )
			{
				fail( "not eq" );
			}
					
					
		}
		
		
		
		
		
		
		
		
	}
}